package com.hq.fxh.No2_BBS.Fragment;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.design.widget.TabLayout;
import android.support.v4.app.Fragment;
import android.support.v4.view.ViewPager;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import com.hq.fxh.No0_ChengQu.Adapter.PAdapter_Home;
import com.hq.fxh.No0_ChengQu.Fragment.BaseFragment;
import com.hq.fxh.R;
import com.hq.fxh.Utils.TabUtils;

import java.util.ArrayList;

/**
 * /**
 *
 * @author 薛
 * @ClassName
 * @Description :论坛看帖框架页
 * @Created 2017/8/17
 * @Email xlwenhao1858@sina.com
 */


public class BBS_KanTie_Fragment extends BaseFragment {
     protected TabLayout tabLayoutKanTie;
    protected ViewPager viewPagerKanTie;

    public static BBS_KanTie_Fragment newInstance() {
        Bundle args = new Bundle();
        BBS_KanTie_Fragment fragment = new BBS_KanTie_Fragment();
        fragment.setArguments(args);
        return fragment;
    }


    @Override
    public int getLayoutId() {
        return R.layout.fragment_kantie;
    }

    @Override
    protected void findView(View rootView) {
        tabLayoutKanTie = (TabLayout) rootView.findViewById(R.id.tabLayout_KanTie);
        viewPagerKanTie = (ViewPager) rootView.findViewById(R.id.viewPager_KanTie);
        ArrayList<Fragment> fragments = new ArrayList<>();
        fragments.add(BBS_KanTie_ContentFragment.newInstance(1));
        fragments.add(BBS_KanTie_ContentFragment.newInstance(2));
        fragments.add(BBS_KanTie_ContentFragment.newInstance(3));
        viewPagerKanTie.addOnPageChangeListener(new TabLayout.TabLayoutOnPageChangeListener(tabLayoutKanTie));
        tabLayoutKanTie.addOnTabSelectedListener(new TabLayout.ViewPagerOnTabSelectedListener(viewPagerKanTie));
        viewPagerKanTie.setAdapter(new PAdapter_Home(getChildFragmentManager(), fragments));
        viewPagerKanTie.setPageMargin(5);
        viewPagerKanTie.setOffscreenPageLimit(5);


    }

    @Override
    protected void initData() {
        TabUtils.setIndicator(tabLayoutKanTie,30,30);

    }


}
